package com.imooc.news_manager_project.common;

import com.imooc.news_manager_project.common.enums.ResultCode;
import com.imooc.news_manager_project.domain.News;
import lombok.Data;

import java.util.List;

@Data
public class Result {
    //状态码
    private Integer code;
    // 信息
    private String msg;
    //返回的对象
    private Object data;

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(Integer code, String msg, String data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(Integer code, String msg, List<News> list) {
        this.code = code;
        this.msg = msg;
        this.data = list;
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = null;
    }

    public Result(ResultCode resultCode) {
        this.code = resultCode.code();
        this.msg = resultCode.message();
        this.data = null;
    }


    public Result(ResultCode resultCode, Object object) {
        this.code = resultCode.code();
        this.msg = resultCode.message();
        this.data = object;
    }

}
